{#美化分类管理页面#}
<!-- templates/admin_categories.html -->
{% extends 'base.html' %}
{% block content %}
<h3>后台 - 分类管理</h3>

{#/admin/categories/add#}
<form method="post" action="{{ url_for('admin.add_category') }}" class="row g-3 mb-3">
    <div class="col-auto">
        <input type="text" class="form-control" name="name" placeholder="新分类名称">
    </div>
    <div class="col-auto">
        <button type="submit" class="btn btn-success">添加分类</button>
    </div>
</form>

<table class="table table-bordered">
    <thead>
        <tr><th>ID</th><th>名称</th><th>操作</th></tr>
    </thead>
    <tbody>
        {% for c in categories %}
        <tr>
            <td>{{ c.id }}</td>
            <td>{{ c.name }}</td>
            <td>
                {#/admin/categories/delete/{{ c.id }}#}
                <form method="post" action="{{ url_for('admin.delete_category', category_id=c.id) }}" style="display:inline-block">
                    <button class="btn btn-sm btn-danger" onclick="return confirm('确认删除该分类？')">删除</button>
                </form>
            </td>
        </tr>
        {% endfor %}
    </tbody>
</table>
{% endblock %}